package com.hw.backapi.controller;

import com.hw.backapi.service.IDiagTaskService;
import com.hw.common.annotation.MyLogAdmin;
import com.hw.common.contants.UrlContants;
import com.hw.model.common.BaseResult;
import com.hw.model.dto.overview.DetailedQueryDTO;
import com.hw.model.dto.overview.OverviewQueryDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 数据统计 : 关于小孩的统计
 */
@RestController
public class DataStatisticsChildController {

    @Autowired
    IDiagTaskService diagTaskServiceImpl;

    /**
     * 数据概览
     * @return
     */
    @PostMapping(UrlContants.DATA_OVERVIEW)
    public BaseResult overview(
            @RequestBody OverviewQueryDTO overviewQueryDTO
    ){
        return BaseResult.ok(diagTaskServiceImpl.overview(overviewQueryDTO));
    }

    /**
     * 数据明细
     * @param detailedQueryDTO
     * @return
     */
    @PostMapping(UrlContants.DATA_DETAIL)
    @MyLogAdmin(label = "数据明细")
    public BaseResult detailed(
        @RequestBody DetailedQueryDTO detailedQueryDTO
    ){
        return BaseResult.ok(diagTaskServiceImpl.detailed(detailedQueryDTO));
    }

    @GetMapping(UrlContants.DATA_EXPORT_BONES_CSV)
    @MyLogAdmin(label = "导出孩子骨骼csv")
    public void exportBonesCsv(
            @RequestParam("ossId") Long ossId, HttpServletResponse response
    ){
        diagTaskServiceImpl.exportBonesCsv(ossId,response);
    }

    @GetMapping(UrlContants.DATA_DETAIL_EXPORT)
    @MyLogAdmin(label = "导出孩子明细")
    public void exportDetailed(
            DetailedQueryDTO detailedQueryDTO
    ){
        diagTaskServiceImpl.exportDetailed(detailedQueryDTO);
    }

    @PostMapping(UrlContants.DATA_BATCH_DOWNLOAD)
    @MyLogAdmin(label = "批量下载孩子文件")
    public void batchDownload(
            @RequestBody DetailedQueryDTO detailedQueryDTO, HttpServletRequest request, HttpServletResponse response
    ){
        diagTaskServiceImpl.batchDownload(detailedQueryDTO,request,response);
    }
}
